-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to persist theme selection #941
Add a way to persist theme selection #941
Conversation
Published version: @draftbit/ui@49.6.8-f99c50.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
}); | ||
|
||
React.useEffect(() => { | ||
const run = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider if the UI shakes slightly during initialization due to the absence of a wait state when loading the theme.
👉 Example: the UI may briefly display with theme1 before switching to theme2, causing a flicker.
If thorough testing shows no issue, you can disregard this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since storage is async, the only way to fix an eventual flicker would be to render nothing and wait on the storage to give back data. Let see if the current approach is working and fix it if it causes flickers!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about the same thing, but saw no flicker during testing. We can always come back to it and fix if the issue does arise at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
}); | ||
|
||
React.useEffect(() => { | ||
const run = async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since storage is async, the only way to fix an eventual flicker would be to render nothing and wait on the storage to give back data. Let see if the current approach is working and fix it if it causes flickers!
Summary:
This PR adds theme persistence using AsyncStorage and updates jest setup files to mock AsyncStorage for testing.
Key points:
@react-native-async-storage/async-storage
to dependencies.AsyncStorage
inProvider.tsx
.SAVED_SELECTED_THEME_KEY
constant for storage key.changeTheme
function to acceptChangeThemeOptions
.React.useEffect
to load persisted theme on initialization.useChangeTheme
hook to supportChangeThemeOptions
.Generated with ❤️ by ellipsis.dev